<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        // 代理Proxy
        let obj = {
            name:"李老师",
            waiter:12
        };
        let handel = {
            // 设置
            set:function(target,key,value){
                console.log('1,李老师的水会进行变化！！！',target,key,value);
                if(value < 0){
                    return;
                }
                target[key] = value;
            },
            // 获取
            get:function(target,key){
                console.log('2,有人想看李老师的水',target,key);
                return target[key];
            }
        }
        let proxy = new Proxy(obj,handel);
        proxy.waiter = -34;
        console.log('结果',proxy);
        console.log('获取',proxy.waiter);
    </script>
</body>
</html>